-- msg_verify_dungeon_action
-- Created by panyl Mar/03/2016
-- 验证地牢

return function(lpc)
    local cookie = lpc.cookie;
    local rid    = lpc.rid;
    local dbase  = lpc.dbase;
    local extra  = lpc.extra;
    local actions = extra.actions;

    -- 创建一个玩家
    ME.produceUser(table.deepcopy(dbase));

    ME.loginNotifyOk();

    -- 先切换迷宫状态
    DungeonM.switchState(DUNGEON_LEAVE);

    -- 初始化一些数据
    DungeonVerifyM.startVerify(dbase, extra);

    -- 构造迷宫
    DungeonM.notifyDungeonData(extra.dungeon, extra.dungeon_context);

    local userData = DungeonLogM.getUserData();

    -- 迷宫行为
    DungeonActionM.doActions(actions);

    -- mapping类型的需要先记录下来，一些确定的需要预先写下来
    local mappingList = {
        ["equipments"] = true,
    };
    for key, v in pairs(lpc.dbase) do
        if type(v) == "table" and v.array ~= true then
            -- mapping类型的
            mappingList[key] = true;
        end
    end

    -- 同步结果
    local result = DungeonVerifyM.packResultData(mappingList);

    local v = {["cookie"] = cookie, ["rid"] = rid, ["result"] = result, ["log"] = userData, };
    Communicate.send("CMD_VERIFY_ACTION_RESULT", v);
end
